package org.cometmi.gwt.chat.client;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;

public class LoginWidget extends Composite
{
	private TextBox userName;
	private PasswordTextBox password;

	private Button doLogin;

	public LoginWidget(ClickHandler onLoginHandler)
	{
		HTML userNameLable = new HTML("User name:");
		HTML passwordLabel = new HTML("Password:");

		this.userName = new TextBox();
		this.password = new PasswordTextBox();
		this.doLogin = new Button("login", onLoginHandler);

		Grid grid = new Grid(3, 2);
		grid.setWidget(0, 0, userNameLable);
		grid.setWidget(0, 1, this.userName);
		grid.setWidget(1, 0, passwordLabel);
		grid.setWidget(1, 1, this.password);
		grid.setWidget(2, 0, this.doLogin);

		ColumnFormatter colFormatter = grid.getColumnFormatter();
		colFormatter.setWidth(0, "100px");
		colFormatter.setWidth(1, "200px");

		initWidget(grid);
	}

	public String getUserName()
	{
		return this.userName.getValue();
	}
}
